import BLEUtil from "@gblh/ble";
import { Button } from "antd";
import { useMemo } from "react";

// import BLEUtil from 'ble-lib';

const DocsPage = () => {
  const util = useMemo(() => {


    BLEUtil.init({ "platform": "WEB", "instance": window, devicePlatform: "WEB" })
    return new BLEUtil.device.BloodPressureTool();


    // return BLEUtil.getInstance({
    //   platform: "WEB",
    //   serviceId: ["974cbe30-3e83-465e-acde-6f92fe712134"]
    // });
  }, [])
  return (
    <div>
      <Button onClick={async () => {
        await util.start({
          onDetecting: () => {

          },
          onEnd: (result) => {
            console.log('result', result)
          }
        });
        // 60秒后断开

        // await util.connect();
        // util.addEventListener("00001810-0000-1000-8000-00805f9b34fb", ["00002a36-0000-1000-8000-00805f9b34fb", "00002a35-0000-1000-8000-00805f9b34fb"], (values) => {
        //   console.log(3333, values);
        //   if (values.uuid === "00002a35-0000-1000-8000-00805f9b34fb") {
        //     util.close();
        //     console.log(`测试结束高压:${values.values[1]},低压:${values.values[3]},脉搏:${values.values[14]},`)
        //   }
        // })
      }} >
        血压仪
      </Button>
    </div>
  );
};

export default DocsPage;
